import { ApiProperty } from '@nestjs/swagger';
import { IsInt, IsString } from 'class-validator';
import {
  Column,
  CreateDateColumn,
  Entity,
  PrimaryGeneratedColumn,
  UpdateDateColumn,
} from 'typeorm';

@Entity()
export class Collection {
  @ApiProperty({ description: 'id' })
  @IsInt()
  @PrimaryGeneratedColumn()
  id: number;

  @ApiProperty({ description: '用户id' })
  @IsString()
  @Column()
  userId: string;

  // @ApiProperty({ description: '是否收藏, 0-未收藏, 1-取消收藏' })
  // @IsString()
  // isCollected: number;

  @ApiProperty({ description: '合辑id', required: false })
  @Column()
  gatherId?: number;

  @ApiProperty({ description: '合辑名称', required: false })
  @Column()
  gatherName?: string;

  // @ApiProperty({ description: '单词', required: false })
  // @Column()
  // word?: string;

  @ApiProperty()
  @CreateDateColumn({ type: 'timestamptz', default: () => 'CURRENT_TIMESTAMP' })
  createdAt: string;

  @ApiProperty()
  @UpdateDateColumn({
    type: 'timestamptz',
    default: () => 'CURRENT_TIMESTAMP',
    onUpdate: 'CURRENT_TIMESTAMP',
  })
  updatedAt: string;
}
